using System.Data.Entity.Migrations;

namespace vm.Aspects.Model.Tests.EFRepository.Migrations
{

    public partial class initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo._HiLoIdentityGenerator",
                c => new
                    {
                        EntitySetName = c.String(nullable: false, maxLength: 100),
                        HighValue = c.Int(nullable: false),
                        MaxLowValue = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.EntitySetName);

            CreateTable(
                "dbo.TestEntity",
                c => new
                    {
                        Id = c.Long(nullable: false),
                        Name = c.String(nullable: false, maxLength: 100),
                        StringProperty = c.String(maxLength: 100),
                        Type = c.String(maxLength: 30),
                        XEntity_Id = c.Long(),
                        Value_Id = c.Long(),
                        Created = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"),
                        Updated = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.TestXEntity", t => t.XEntity_Id)
                .Index(t => t.XEntity_Id);

            CreateTable(
                "dbo.TestValue",
                c => new
                    {
                        Id = c.Long(nullable: false),
                        Name = c.String(nullable: false, maxLength: 100),
                        Entity2_Id = c.Long(),
                        Entity_Id = c.Long(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.TestEntity", t => t.Entity2_Id)
                .ForeignKey("dbo.TestEntity", t => t.Entity_Id)
                .Index(t => t.Entity2_Id)
                .Index(t => t.Entity_Id);

            CreateTable(
                "dbo.TestXEntity",
                c => new
                    {
                        Id = c.Long(nullable: false),
                        Name = c.String(nullable: false, maxLength: 100),
                        StringProperty = c.String(maxLength: 100),
                        Created = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"),
                        Updated = c.DateTime(nullable: false, precision: 7, storeType: "datetime2"),
                    })
                .PrimaryKey(t => t.Id);

        }

        public override void Down()
        {
            DropForeignKey("dbo.TestEntity", "XEntity_Id", "dbo.TestXEntity");
            DropForeignKey("dbo.TestValue", "Entity_Id", "dbo.TestEntity");
            DropForeignKey("dbo.TestValue", "Entity2_Id", "dbo.TestEntity");
            DropIndex("dbo.TestValue", new[] { "Entity_Id" });
            DropIndex("dbo.TestValue", new[] { "Entity2_Id" });
            DropIndex("dbo.TestEntity", new[] { "XEntity_Id" });
            DropTable("dbo.TestXEntity");
            DropTable("dbo.TestValue");
            DropTable("dbo.TestEntity");
            DropTable("dbo._HiLoIdentityGenerator");
        }
    }
}
